#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define LEN 20

int main(int argc, char *argv[])
{
	FILE *fp;
	char ch;
	int i;
	int count = 0;
	if(argc < 3)
	{
		fprintf(stderr, "Usage: %s filename\n", argv[0]);
		exit(EXIT_FAILURE);
	}
	for(i=2; i<argc; i++){
		if((fp = fopen(argv[i], "r")) == NULL)
		{
			fprintf(stderr, "can't open the file:\n");
			exit(EXIT_FAILURE);	
		}
		while((ch = getc(fp)) != EOF)
		{
			char str[2];
			str[0] = ch;
			str[1] = '\0';
			if(strcmp(str,argv[1]) == 0)
				count++;
		}	
	}
	printf("%d\n",count);
	if((fclose(fp)) != 0)
		fprintf(stderr, "close file failed");
	return 0;	
} 
